Skip to content

Accelerate integer primitives and expand performance coverage - #1021

Merged
AArnott merged 7 commits into
mainfrom
aarnott-expand-perf-benchmarks
Jul 24, 2026
Merged

AArnott merged 7 commits into
mainfrom
aarnott-expand-perf-benchmarks

Conversation

@AArnott

@AArnott AArnott commented Jul 24, 2026

Copy link
Copy Markdown
Owner

This improves hot MessagePack integer encoding and decoding paths while establishing broader, repeatable performance coverage for future optimization work.

  • Optimizes int32 fixint encoding and decoding, and removes allocations while enumerating collection converters.
  • Adds integer distribution benchmarks with branch and disassembly diagnostics, plus populated large-model and default-settings POCO benchmarks.
  • Adds primitive codec tests, refreshes performance reports, and documents the performance optimization workflow for AI-assisted changes.

The integer benchmarks use fixed-seed Small, Mixed, and Large workloads to make branch-sensitive results reproducible. Hardware-counter collection requires an elevated Windows process.

AArnott and others added 5 commits July 24, 2026 11:47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 23:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves hot-path MessagePack integer primitive encoding/decoding and broadens the repository’s performance coverage by adding new BenchmarkDotNet suites and updating the accompanying performance docs/workflow guidance.

Changes:

  • Optimized int fixint write path and added a fast-path Int32 reader for fixint and Int32/UInt32 payload forms.
  • Added/expanded performance benchmarks (integer distributions, default-settings POCO comparisons, and a larger data model scenario) plus refreshed performance documentation/report notes.
  • Added primitive codec tests covering Int32 fixint, Int32 payload, insufficient buffer behavior, and unsigned overflow behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Nerdbank.MessagePack.Tests/MessagePackPrimitivesTests.cs Adds targeted primitive decoding tests for Int32 to validate optimized paths and edge cases.
test/Benchmarks/update-benchmarks-report.ps1 Updates the benchmark-report workflow guidance to current BenchmarkDotNet invocation patterns.
test/Benchmarks/SimplePoco.cs Adds default-settings POCO benchmarks alongside existing configured-serializer comparisons.
test/Benchmarks/LargeDataModelBenchmark.cs Introduces a larger data-model benchmark for more realistic serialize/deserialize throughput/allocation tracking.
test/Benchmarks/IntegerPrimitives.cs Adds branch-sensitive integer primitive benchmarks with diagnosers/counters for repeatable perf analysis.
src/Nerdbank.MessagePack/MessagePackPrimitives.Writers.cs Optimizes int fixint encoding by collapsing positive/negative fixint handling into a single fast check.
src/Nerdbank.MessagePack/MessagePackPrimitives.Readers.Integers.tt Updates the T4 template to emit the Int32 fast-path reader logic and a non-inlined fallback.
src/Nerdbank.MessagePack/MessagePackPrimitives.Readers.Integers.cs Implements the generated Int32 fast-path reader plus a no-inlining fallback helper.
src/Nerdbank.MessagePack/Converters/EnumerableConverter`2.cs Reduces allocations/overhead by special-casing List<T> writes via a no-inlined concrete path.
src/Nerdbank.MessagePack/Converters/DictionaryConverter`3.cs Special-cases Dictionary<TKey,TValue> enumeration via a no-inlined concrete path.
docfx/includes/perf.md Refreshes performance report content/axes and adds clarifying provenance text.
docfx/docs/performance.md Updates narrative guidance around relative performance comparisons and benchmark interpretation.
AGENTS.md Documents the perf optimization workflow/benchmark baseline commands for contributors and agents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md
Comment thread src/Nerdbank.MessagePack/MessagePackPrimitives.Writers.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 23:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread src/Nerdbank.MessagePack/MessagePackPrimitives.Writers.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 23:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

@AArnott
AArnott merged commit ae9062e into main Jul 24, 2026
8 checks passed
@AArnott
AArnott deleted the aarnott-expand-perf-benchmarks branch July 24, 2026 23:32
Comment thread src/Nerdbank.MessagePack/Converters/DictionaryConverter`3.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants